
<div class="from-add-01" style="width:400px;float:left;">
<h2><?php echo $this->page_title; ?></h2>
<ul>
	<li>
		<label>Full Name:</label>
		<?php echo $this->userInfo['full_name']; ?>
	</li>
	<li>
		<label>Job Title:</label>
		<?php echo $this->userInfo['job_title']; ?>
	</li>
	<li>
		<label>UserName:</label>
		<?php echo $this->userInfo['username']; ?>
		
	</li>
	<li>
		<label>Phone</label>
		<?php echo $this->userInfo['phone']; ?>
	</li>
	<li>
		<label>Email:</label>
		<?php echo $this->userInfo['email']; ?>
	</li>
</ul>
<div align="center">
		<a href="/user"><input type="button"  value="cancel" class="button02"></a> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
		<input type="button" id="edit" value="Edit" class="button01"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
		<input type="button" id="change_password" value="Change Password" class="button01">
</div>
<div id="hide1" style="float:left;width:500px;display:none; ">
<form name="frm" action="/user/edit-user" method="post" onsubmit="return checkValid1()">
<input type="hidden" id="consultant_id" name="id" value="<?php echo $this->userInfo['consultant_id']; ?>">
	<ul>
		<li>
			<label></label>
			<em class="error"></em>
		</li>
        <li>
            <label>User Name:<em>*</em></label>
            <input type="text" id="username" name="username" value="<?php echo $this->userInfo['username']; ?>" disabled="disabled">
        </li>
		<li>
			<label>Full Name:<em>*</em></label>
			<input type="text" id="full_name" name="full_name" value="<?php echo $this->userInfo['full_name']; ?>">
		</li>
		<li>
			<label>Job Title:</label>
			<input type="text" id="job_title" name="job_title" value="<?php echo $this->userInfo['job_title']; ?>">
		</li>
		<li>
			<label>Phone:</label>
			<input type="text" id="phone" name="phone" value="<?php echo $this->userInfo['phone']; ?>">
		</li>
		<li>
			<label>Email:</label>
			<input type="text" id="email"  name="email" value="<?php echo $this->userInfo['email']; ?>" disabled="disabled">
		</li>
 	</ul>
 	<div align="center">
 		<input type="button" class="button02" value="cancel" id="cancel"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 		<input type="submit" class="button01" value="Edit" name="submit" >
 	</div>
</form>	
</div>
<div id="hide2" style="float:left;width:500px;display:none;">
	<form action="/user/change-password" method="post" onsubmit="return checkValid2()">
	<input type="hidden" id="id" name="id" value="<?php echo $this->userInfo['consultant_id']; ?>">
		<ul>
			<li>
			<label></label>
			<em class="false" style="color:red"></em>
			</li>
			<li>
				<label>Current Password:<em>*</em> </label>
				<input type="password" name="password" id="password">
			</li>
			<li>
				<label>New Password:<em>*</em> </label>
				<input type="password" name="password1" id="password1">
			</li>
			<li>
				<label>Confirm Password:<em>*</em> </label>
				<input type="password" name="password2" id="password2">
			</li>
		</ul>
		<div align="center"  style="clear:both">
			<input type="button" id="cancel1" class="button02" value="Cancel"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
			<input type="submit" class="button01" value="Change">
		</div>
	</form>
</div>
</div>
<script>
	$(document).ready(function(){
		$("#edit").click(function(){
			$("#hide1").show('fast');
			$("#hide2").hide('fast');
		});
		$("#cancel").click(function(){
			$("#hide1").hide('fast');
		});
		$("#change_password").click(function(){
			$("#hide2").show('fast');
			$("#hide1").hide('fast');
		});
		$("#cancel1").click(function(){
			$("#hide2").hide('fast');
		});
	});
</script>
<script>
function checkValid1()
{
	var username = $("#username").val();
	var full_name = $("#full_name").val();
	var email = $("#email").val();

	if(username == '')
	{
		$(".error").html("Please enter username.");
		return false;
	}
    
	if(full_name == '')
	{
		$(".error").html("Please enter your name.");
		return false;
	}
	
	var check = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
    if(!check.test(email))
    {
    	$('.error').html('please enter a valid email address');
    	return false;
    }
    return true;
}
</script>
<script>
	function checkValid2()
	{	
		//alert(2222); return false;

		var password = $("#password").val();
		var password1 = $("#password1").val();
		var password2 = $("#password2").val();
		var id = $("#id").val();
		if(password == '')
		{
			$(".false").html("please enter current password.");
			$("#password").focus();
			return false;
		}else{
			$.ajax({
				type : "POST",
				url  : "/user/check-password",
				data : {password: password, id : id},
				success : function(result){
					if(result == 0){
						
						$(".false").html("Current password incorrect.");
						$("password").focus();
						return false;
					}
				}					
			});
		
			if(password1 == ''){
				$(".false").html("please enter new password.");
				$("#password1").focus();
				return false;
			}else{
				if(password1 != password2){
					$(".false").html("Password validation does not match the password.");
					$("#password2").focus();
					return false;
					}else{
						alert('the password change successfully.');
						return true;
					}
				}
			
		}
					
		return true;

	}
</script>